package org.halk.servie.impl;

import org.halk.pojo.entity.StudentTest;
import org.halk.repository.StudentTestRepository;
import org.halk.servie.TestService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Author halk
 * @Date 2023/9/11 11:38
 */
@Service
public class TestServiceImpl implements TestService {

    @Resource
    private StudentTestRepository studentTestRepository;

    @Override
    @Transactional(propagation = Propagation.NESTED)
    public void test01() {
        StudentTest studentTest = studentTestRepository.findById(2).get();
        System.out.println(studentTest);
        studentTest.setAge(34343);
        studentTestRepository.save(studentTest);

//        test02();

//        throw new RuntimeException("dfddd");
    }

    //    @Transactional
    public void test02() {

        StudentTest studentTest = studentTestRepository.findById(2).get();
        System.out.println(studentTest);
        studentTest.setAge(55);
        studentTestRepository.save(studentTest);
        int i = 1 / 0;
    }
}
